﻿using VsxFactory.Modeling.VisualStudio;
using System;

namespace VsxFactory.Modeling.Strategies.VisualStudio
{
    class VSFolder : VSContainer, IVsFolder
    {
        public VSFolder(IVsSolution solution, HierarchyNode node)
            : base(solution, node)
        {
            System.Diagnostics.Contracts.Contract.Requires(node != null);
        }

        public string Path
        {
            get { return node.Path; }
        }

        public IVsProjectFileItem AddItem(string fileName, byte[] content = null)
        {
            System.Diagnostics.Contracts.Contract.Requires(!String.IsNullOrWhiteSpace(fileName));
            var pi = ((ProjectNode)node).AddItem(fileName, content);
            var project = new VSProject(this.Solution, node.GetContainingProject());
            return pi != null ? new VSProjectItem(project, pi) : null;
        }

        public void AddItemAsLink(string fileName)
        {
            System.Diagnostics.Contracts.Contract.Requires(!String.IsNullOrWhiteSpace(fileName));
            ((ProjectNode)node).AddItemAsLink(fileName);
        }

    }
}
